<?php
/**
 * Created by PhpStorm.
 * User: dancheng
 * Date: 2018/1/19
 * Time: 8:58
 */
function check_token($th){
    if($th->input->is_ajax_request()){
        if(isset($_POST['token'])){
            $token = $_POST['token'];
        } else if(isset($_GET['token'])){
            $token = $_GET['token'];
        } else {
            $token = '0';
        }
        if($token === token_key){
            $token_data = [
                'tag' => 1,
                'msg' => 'token合法，可以访问',
            ];
        } else {
            $token_data = [
                'tag' => 0,
                'msg' => 'token不合法，不可以访问',
            ];
        }
        return $token_data;
    }
}